class RouterVueRouter{
    constructor(options) {
        this.options= options
        this.routes = {}
        this.currentHash = ''
        // 创建hash表
        this.createRouterMap.bind(this,options)
        // 初始化， 用于监听页面路由改变
        this.init()
    }
    init() {
        window.addEventListener('load', this.setHash.bind(this), false)
        window.addEventListener('hashchange', this.setHash.bind(this), false)
    }
    createRouterMap(){
        this.options.map(item => {
            this.routes[item.path] = item.component
        })
    }
    // 获取当前的hash
    getHash() {
        return location.hash.slice(1) || '/'
    }
    // 设置当前hash
    setHash() {
        this.currentHash  = this.getHash()
    }
}
